-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update messaging for measuring message delay between App and Hub #2499
Conversation
61059e3
to
fe1cd61
Compare
0ad25a2
to
114df12
Compare
7b23b3f
to
2c4236f
Compare
28f9abb
to
3733b01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
9ccaa4d
to
c987c5b
Compare
c987c5b
to
2eca21a
Compare
Just FYI, I think @TrevorJoelHarris has checked in a code refactoring how communication works. You might have to rebase on that and make changes accordingly. @juanscr |
Yeah, I thought there was going to be an issue with Trevor's changes. But everything is still compliant with this PR, the sync is made tho. Later down the line when the |
With this new timestamped messaged, the host can properly compare and evaluate how much time the request got delayed to an issue on a busy event loop.
This new handler will allow any application developer to register a function for analyzing or storing performance metrics related to latencies due to a message delay sending the response back from the host to the app.
The old field will be preserved with backwards compatibility with previous versions that still consume this field.
All the telemetry related code is added to the telemetry module to avoid cluttering the communication layer with nuances about telemetry.
602dfbc
to
410ede6
Compare
const targetWindow = Communication.parentWindow; | ||
const request = createMessageRequest(apiVersionTag, actionName, args); | ||
HostToAppMessageDelayTelemetry.storeCallbackInformation(request.uuid, { | ||
name: actionName, | ||
calledAt: request.timestamp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juanscr isnt this "calledAt" supposed to be the monotonicTimestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sumathin-lang, not necessarily. This information is merely contextual around when the callback happened and isn't used for any calculation. I selected the date instead of the monotonicTimestamp
as it should be more proper for a global timestamp as it does not possess issues as not ticking while sleeping and so forth (w3c/hr-time#115 (comment)). I can change it to monotonicTimestamp
if you want but it's a minute detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juanscr I would suggest using the same "units" for messageDelay and calledAt. Even if the App wants to use this "calledat" to measure some kind of delta, perf.now is a better choice compared to date,now. But i will let the teams-js team make this call
Description
This pull request has two purposes:
For the second purpose, with this PR, an app developer can register a function that receives the message delays per function call as soon as a response is received from the host so they can log it or store it in their own telemetry. As app developers do not have information about the internal message IDs, the handler gets passed information about the callback that is resolving so they can approximately pinpoint which call had that message delay.
Note: it was decided to not expose message IDs as it is a really big architectural change in the codebase and the value of exposing them to app developers would be really small in comparison to the change.
Main changes in the PR:
Date.now()
to useperformance.now() + performance.timeOrigin
.Validation
Validation performed:
Unit Tests added:
Yes
End-to-end tests added:
No
Additional Requirements
Change file added:
Yes
Data
This is the response message delay for get context:
This is the request message delay for one-way traffic such as change theme: (this one shows more longer timestamps)
This is the request message delay for onw-way traffic
fullScreenChanged
: